import { createStore } from "vuex";

import UserModel from "./user";
import FoodModel from "./food";
import OrderModel from "./order";
import ChefModel from "./chef";
import ClientModel from "./client";
import CanCookModel from "./can_cook";
import FoodMaterialModel from "./food_material";
import FoodStyleModel from "./food_style";
import ManagerModel from "./manager";
import MaterialModel from "./material";
import OrderItemModel from "./order_item";
import TableModel from "./table";
import ServerModel from "./server";
import ReviewModel from "./review";

const oiArray: any[] = [];
const oArray: any[] = [];

export default createStore({
  state: {
    is_login: false,
    waitting_order_item_list: oiArray,
    waitting_order_list: oArray,
    notice_page: 0,
    jwt_token: "",
  },
  getters: {},
  mutations: {
    addOrderToWaittingList(state, data) {
      if (state.waitting_order_list.length == 0) {
        state.waitting_order_list = [];
      }
      state.waitting_order_list.push(data);
    },
    addOrderItemToWaittingList(state, data) {
      if (state.waitting_order_item_list.length == 0) {
        state.waitting_order_item_list = [];
      }
      state.waitting_order_item_list.push(data);
    },
    setNoticePage(state, data) {
      state.notice_page = data;
    },
  },
  actions: {},
  modules: {
    user: UserModel,
    food: FoodModel,
    order: OrderModel,
    can_cook: CanCookModel,
    food_style: FoodStyleModel,
    manager: ManagerModel,
    material: MaterialModel,
    order_item: OrderItemModel,
    table: TableModel,
    chef: ChefModel,
    client: ClientModel,
    food_material: FoodMaterialModel,
    server: ServerModel,
    review: ReviewModel,
  },
});
